﻿using System.Xml.Linq;

namespace umbraco.DataServices.Linq
{
    public static class Extensions
    {
        public static bool IsDocument(this XElement element) {
            return element.Attribute("isDoc") != null;
        }

        public static bool IsProperty(this XElement element) {
            return element.Attribute("isDoc") == null;
        }

        public static bool HasAliasOf(this XElement element, string alias) {
            if (string.IsNullOrEmpty(alias))
                return false;
            var aliasAttr = element.Attribute("alias");
            if (aliasAttr == null)
                return false;
            return aliasAttr.Value == alias;
        }
    }
}
